//
//  LZGroupDetailTopCell.m
//  laziz_Merchant
//
//  Created by xbnzd on 16/12/20.
//  Copyright © 2016年 XBN. All rights reserved.
//

#import "LZGroupDetailTopCell.h"
#import "GiftListLabel.h"
#import "LZCouponListModel.h"
#import "LZDateFormatterManager.h"

@interface LZGroupDetailTopCell()
@property (weak, nonatomic) IBOutlet GiftListLabel *groupTitleLabel;  //title
@property (weak, nonatomic) IBOutlet UILabel *groupLabel;  //成团数量要求
@property (weak, nonatomic) IBOutlet UILabel *groupCountLabel;  //数量
@property (weak, nonatomic) IBOutlet UILabel *groupTimeRemainLabel;   //剩余时间
@property (weak, nonatomic) IBOutlet UILabel *groupTimeRemainTimeLabel;  //时间


@end

@implementation LZGroupDetailTopCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    _groupLabel.text = LZLocalizedString(@"quatity_of_groups_formed", nil);
    _groupTimeRemainLabel.text = LZLocalizedString(@"time_remaining", nil);
    self.groupTitleLabel.preferredMaxLayoutWidth = SCREEN_WIDTH - 20;
}


- (void)loadContentWithData:(LZCouponListModel *)dataModel
{
    [self setTitleContentLabelText:dataModel.grouponName];
    self.groupCountLabel.text = [NSString stringWithFormat:@"%d",dataModel.grouponFinishCount];
    self.groupTimeRemainTimeLabel.text = [[LZDateFormatterManager shareInstance] returnRemainingHMTimeWithEndTime:dataModel.grouponEndTime];
}

- (void)setTitleContentLabelText:(NSString *)text
{
    if (text.length <= 0) {
        return;
    }
    extern CGFloat textLineSpace;
    NSMutableAttributedString *attStr = [[NSMutableAttributedString alloc] initWithString:text];
    NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
    
    [style setLineSpacing:textLineSpace];
    [style setLineBreakMode:NSLineBreakByWordWrapping];
    [style setAlignment:NSTextAlignmentNatural];
    
    [attStr addAttribute:NSParagraphStyleAttributeName value:style range:NSMakeRange(0, attStr.length)];
    self.groupTitleLabel.attributedText = attStr;
}

#pragma mark -
#pragma mark action
- (void)configureLabel
{
    [self.groupTitleLabel setVerticalAlignment:VerticalAlignmentTop];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
